function addButton ( idTag ) 
{
	    var element = document.createElement( "input" );
	    element.setAttribute( "type", 'button' ); 
	    element.setAttribute( "value", 'Remove' );
	    element.setAttribute( "name", 'Remove' );
	    var doc = document.getElementById( idTag );
	    doc.appendChild( element );
}

function addCheck ( idTag ) 
{
	    var element = document.createElement("input");
	    element.setAttribute( "type", 'checkbox' );
	    element.setAttribute( "value", 'Show' );
	    element.setAttribute( "name", 'Show' );
	    var doc = document.getElementById( idTag );
	    doc.appendChild( element );
}

function getList(gadgets)
{

	document.write("<table> <tbody>");
	for( var i in gadgets)
	{
	document.write("<tr> <td align='left'>" + gadgets[i].title + "</td> <td align='right' id='" + i + "'> </td> </tr>");
	}
	document.write("</tbody> </table>");
	for( var i in gadgets)
	{
	addButton(i);
	addCheck(i);
	}
	document.write("<br><input type='text' id='getURL'/> <input type='submit' value='Add Gadget!' onclick='addGadget()'/>");

}

gadgets.rpc.call("", "getGadgets", getList, null);